#example6_26_3D_surface.py
#coding=utf-8
import numpy as np
import matplotlib.pyplot as plt

n = 512
x = np.linspace(-2.5, 2.5, n)
y = np.linspace(-2.5, 2.5, n)
# 将x、y变成网格数据
X,Y = np.meshgrid(x, y)
# 根据X、Y的值计算Z
Z = (X**3 + Y)*np.exp(-X**2-Y**2)

plt.rcParams['font.sans-serif'] = ['SimHei'] 
# 用来正常显示负号
plt.rcParams['axes.unicode_minus'] = False  
plt.rcParams['font.size']=15  #改变默认字体大小

fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111, projection='3d') #创建三维坐标子图
ax.plot_surface(X,Y,Z)
ax.set_xlabel('X轴')
ax.set_ylabel('Y轴')
ax.set_zlabel('Z轴')
plt.title("三维曲面图")

plt.show()
